package com.danguo.happymonkey;

import com.danguo.happymonkey.R;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.TextView;

public class LessonOneActivity extends Activity
{
   /** Hold a reference to our GLSurfaceView */
   private LessonOneGLSurfaceView theGLview;
   //private LinearLayout theMenu;
   //private ImageView theFleetYardMarker;
   //private ImageView theFleetMarker1;
   //private ImageView theFleetMarker2;

   @Override
   public void onCreate( Bundle savedInstanceState )
   {
      super.onCreate( savedInstanceState );

      // Check if the system supports OpenGL ES 2.0.
      final ActivityManager activityManager = (ActivityManager) getSystemService( Context.ACTIVITY_SERVICE );
      final ConfigurationInfo configurationInfo = activityManager
            .getDeviceConfigurationInfo();
      final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;

      if( supportsEs2 )
      {
         setContentView( R.layout.activity_lesson_one );
         theGLview = (LessonOneGLSurfaceView)findViewById( R.id.gls );
         
//         theMenu = (LinearLayout) findViewById( R.id.output );
//         theFleetYardMarker = (ImageView) findViewById( R.id.fleetyard );
//         theFleetMarker1 = (ImageView) findViewById( R.id.fleet1 );
//         theFleetMarker2 = (ImageView) findViewById( R.id.fleet2 );
//         
//         theFleetYardMarker.setVisibility( View.INVISIBLE );
//         theFleetMarker1.setVisibility( View.INVISIBLE );
//         theFleetMarker2.setVisibility( View.INVISIBLE );
         
      } else
      {
         // This is where you could create an OpenGL ES 1.x compatible
         // renderer if you wanted to support both ES 1 and ES 2.
         FrameLayout f = new FrameLayout( this );
         TextView msg = new TextView( this );
         msg.setText( "Open GL ES 2 is not supported by this device" );
         f.addView( msg );
         setContentView( f );
         return;
      }
   }

   @Override
   protected void onResume()
   {
      // The activity must call the GL surface view's onResume() on activity
      // onResume().
      super.onResume();
 
      if( theGLview != null ){ theGLview.onResume(); }
   }

   @Override
   protected void onPause()
   {
      // The activity must call the GL surface view's onPause() on activity
      // onPause().
      super.onPause();
 
      if( theGLview != null ){ theGLview.onPause(); }
   }
   
//   public void setSelected( int aPoint )
//   {
//      switch( aPoint )
//         {
//         case -1:
//            theMenu.setBackgroundResource( R.drawable.sys_none );
//            theFleetYardMarker.setVisibility( View.INVISIBLE );
//            theFleetMarker1.setVisibility( View.INVISIBLE );
//            theFleetMarker2.setVisibility( View.INVISIBLE );
//         break;
//         case 0:
//            theMenu.setBackgroundResource( R.drawable.sys_deneb );
//            theFleetYardMarker.setVisibility( View.INVISIBLE );
//            theFleetMarker1.setVisibility( View.VISIBLE );
//            theFleetMarker2.setVisibility( View.INVISIBLE );
//         break;
//         case 1:
//            theMenu.setBackgroundResource( R.drawable.sys_orion );
//            theFleetYardMarker.setVisibility( View.VISIBLE );
//            theFleetMarker1.setVisibility( View.VISIBLE );
//            theFleetMarker2.setVisibility( View.VISIBLE );
//         break;
//         case 2:
//            theMenu.setBackgroundResource( R.drawable.sys_altair );
//            theFleetYardMarker.setVisibility( View.INVISIBLE );
//            theFleetMarker1.setVisibility( View.INVISIBLE );
//            theFleetMarker2.setVisibility( View.INVISIBLE );
//         break;
//         }
//   }
//   
//   public void openFleetYard( View aView )
//   {
//      Toast.makeText( this, "This is where you will create new ships", Toast.LENGTH_LONG ).show();
//   }
//   public void orderFleet( View aView )
//   {
//      Toast.makeText( this, "This is where you will order your fleet", Toast.LENGTH_LONG ).show();
//   }
}
